package org.perla.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 */
@Entity
@Table(name = "temperature")
@NamedQueries({
    @NamedQuery(name = "Temperature.findAll", query = "SELECT t FROM Temperature t"),
    @NamedQuery(name = "Temperature.findByIdSensore", query = "SELECT t FROM Temperature t WHERE t.temperaturePK.idSensore = :idSensore"),
    @NamedQuery(name = "Temperature.findByValue", query = "SELECT t FROM Temperature t WHERE t.value = :value"),
    @NamedQuery(name = "Temperature.findByTimestamp", query = "SELECT t FROM Temperature t WHERE t.temperaturePK.timestamp = :timestamp"),
    @NamedQuery(name = "Temperature.findByIdNodo", query = "SELECT t FROM Temperature t WHERE t.temperaturePK.idNodo = :idNodo")})
public class Temperature implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TemperaturePK temperaturePK;
    @Column(name = "value")
    private Double value;

    public Temperature() {
    }

    public Temperature(TemperaturePK temperaturePK) {
        this.temperaturePK = temperaturePK;
    }

    public Temperature(String idSensore, long timestamp, String idNodo) {
        this.temperaturePK = new TemperaturePK(idSensore, timestamp, idNodo);
    }

    public TemperaturePK getTemperaturePK() {
        return temperaturePK;
    }

    public void setTemperaturePK(TemperaturePK temperaturePK) {
        this.temperaturePK = temperaturePK;
    }

    public Double getValue() {
        return value;
    }

    public void setValue(Double value) {
        this.value = value;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (temperaturePK != null ? temperaturePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Temperature)) {
            return false;
        }
        Temperature other = (Temperature) object;
        if ((this.temperaturePK == null && other.temperaturePK != null) || (this.temperaturePK != null && !this.temperaturePK.equals(other.temperaturePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.perla.entities.Temperature[temperaturePK=" + temperaturePK + "]";
    }

}
